/**
 * \file log.h
 * \brief Event log
 * \author Radim Badsi <radim.badsi@polytech.univ-montp2.fr>
 * \date 12/07/2010
 */

#ifndef LOG_H
#define LOG_H

#include "smallsatos.h"

/**
  * Event log queue size (number of messages)
  */
#define EVENT_LOG_QUEUE_SIZE 5

/**
  * Message priority
  */
typedef enum
{
	PRIO_LOW = 0x0, PRIO_MEDIUM = 0x0F, PRIO_HIGH = 0xFF
} event_priority_t;

/**
  * Event types
  */
typedef enum
{
	EV_RESET_GENERAL = 0,
	EV_RESET_CONTROLEUR = 1,
	EV_RESET_EXPERIENCE = 2,
	EV_RESET_RADIO = 3,
	EV_DEBUT_MESURES = 4,
	EV_FIN_MESURES = 5,
	EV_DEBUT_MESURE_DOSE = 6,
	EV_FIN_MESURE_DOSE = 7,
	EV_DEBUT_EMISSION = 8,
	EV_FIN_EMISSION = 9,
	EV_MODE_MISSION = 10,
	EV_MODE_VEILLE = 11,
	EV_ARRET_EMISSION = 12,
	EV_CONFIG_GAIN = 13,
	EV_CONFIG_TIMERS = 14,
	EV_NIVEAU_CRITIQUE_BATTERIE = 15,
	EV_ETAT_CAN = 16,
	EV_ERREUR_I2C = 17,
	EV_ERREUR_TEST_CAN = 18,
	EV_ERREUR_TEST_EEPROM = 19,
	EV_ERREUR_PERSISTANCE_EEPROM = 20,
	EV_PANNE_OSCILLATEUR = 21
} event_code_t;

/**
  * Structure of an event
  */
typedef struct
{
	unsigned char code;
	unsigned int value;
} event_t;

/**
  * Return a pointer to the event log mbox
  * @return pointer to the event log mbox
  */
OS_EVENT* get_event_log_mbox(void);

/**
  * Event log (OS task)
  */
void event_log(void* pdata);

#endif